package cn.dzh.controller;


import cn.dzh.model.dto.HttpResult;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.validation.ConstraintViolationException;
import javax.validation.UnexpectedTypeException;

/**
 * @version V1.0
 * @description:
 * @author: dzd
 * @date: 2023/9/7
 */
@RestControllerAdvice
public class ExceptionController {
    @ExceptionHandler(BindException.class)
    public HttpResult handler(BindException e){
        return HttpResult.error(400,"非法参数",e);
    }





    @ExceptionHandler(ConstraintViolationException.class)
    public HttpResult handler(ConstraintViolationException e){
        return HttpResult.error(400,"非法参数",e);
    }


    @ExceptionHandler(UnexpectedTypeException.class)
    public HttpResult handler(UnexpectedTypeException e){
        return HttpResult.error(400,"非法参数",e);
    }



}
